package com.example.common.utils;

////    /**
////     * 恶汉
////     */
////    private static StateBarUtils instance=new StateBarUtils();
//
//    private volatile static StateBarUtils instance=null;
//
//
//    private StateBarUtils(){}
//
//    static class HOLDER{
//        private static StateBarUtils INSTANCE=new StateBarUtils();
//    }
//
//    /**
//     * 线程安全的懒汉
//     * @return
//     */
//    public static StateBarUtils getInstance(){
////        return HOLDER.INSTANCE;
////        return instance;
//
//        /**
//         * 线程不安全的懒汉
//         */
//        if (null==instance){
//            synchronized (StateBarUtils.class){
//                if (null==instance){
//                    instance=new StateBarUtils();
//                }
//            }
//
//        }
//        return instance;
//    }

import android.app.Activity;

//import com.gyf.immersionbar.ImmersionBar;

import com.gyf.immersionbar.ImmersionBar;

import java.lang.ref.WeakReference;

public class StateBarUtils {

    private StateBarUtils(){}

    static class HOLDER{
        private static StateBarUtils INSTANCE=new StateBarUtils();
    }

    public static StateBarUtils getInstance(){
        return HOLDER.INSTANCE;
    }

    /**
     * 处理沉浸式状态栏
     */
    public void doStateBar(Activity activity,int color){
        WeakReference<Activity> activityWeakReference=new WeakReference<>(activity);

        ImmersionBar.with(activityWeakReference.get()).statusBarColor(color)
                .fitsSystemWindows(true).init();
    }
}
